﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using MaxStudio.Concrete.DBUtility;
using MaxStudio.Concrete.Server;
using MaxStudio.Concrete.Server.Service;
using MaxStudio.Concrete.Server.Dao;

namespace MaxStudio.Concrete.Component
{
    public static class MasterDateString
    {
        public static string GetMasterDataNameById(int masterDataId)
        {
            MasterDataService masterDataServiceObj = ServiceFactory.getMasterDataService();
            tb_MasterData entity = new tb_MasterData();

            OperationResult<tb_MasterData> result = masterDataServiceObj.GetMasterDateById(masterDataId);
            if (result.operationSuccess)
            {
                entity = result.obj;
                return entity.Name;
            }
            else
            {
                return "Error";
            }
        }
        
        #region Vender
        public static string GetVenderNameById(int venderId)
        {
             RMVenderService rmVenderService = ServiceFactory.getRMVenderService();
            tb_RMVender entity = new tb_RMVender();

            OperationResult<tb_RMVender> result = rmVenderService.GetRMVenderById(venderId);
            if (result.operationSuccess)
            {
                entity = result.obj;
                return entity.Name;
            }
            else
            {
                return "Error";
            }
        }

        #endregion

        #region User
        public static string GetUserNameById(int userId)
        {
            UserService userServiceObj = ServiceFactory.getUserService();
            tb_User entity = new tb_User();

            OperationResult<tb_User> result = userServiceObj.GetUserById(userId);
            if (result.operationSuccess)
            {
                entity = result.obj;
                return entity.CNName;
            }
            else
            {
                return "Error";
            }
        }

        #endregion
    }
}
